package com.ssm.user.designPattern.filterPattern;

import java.util.ArrayList;
import java.util.List;

public class filterPatternDemo {
    public static void main(String[] args) {
        // 数据初始化
        List<People> personList = new ArrayList<People>();
        personList.add(new People("张美丽", GenderEnum.FEMALE, MaritalTypeEnum.DIVORCED));
        personList.add(new People("老张", GenderEnum.MALE, MaritalTypeEnum.MARRIED));
        personList.add(new People("小明", GenderEnum.MALE, MaritalTypeEnum.UNMARRIED));
        personList.add(new People("李花花", GenderEnum.FEMALE, MaritalTypeEnum.MARRIED));
        personList.add(new People("王五", GenderEnum.MALE, MaritalTypeEnum.MARRIED));
        personList.add(new People("王麻子", GenderEnum.MALE, MaritalTypeEnum.WIDOWED));

        //过滤女性
        GenderFilter girlFilter = new GenderFilter(GenderEnum.FEMALE);
        List<People> people = girlFilter.doFilter(personList);
        System.out.println(people);


        //过滤男性且未婚
        GenderFilter boyFilter = new GenderFilter(GenderEnum.MALE); //男性过滤器
        MaritalTypeFilter maritalTypeFilter = new MaritalTypeFilter(MaritalTypeEnum.UNMARRIED); //未婚过滤器
        List<People> people1 = maritalTypeFilter.doFilter(boyFilter.doFilter(personList)); //双重过滤
        System.out.println(people1);
    }
}
